﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Business.Manager;
using Business.IManager;

namespace OnlinePayment.Admin
{
    public partial class OperatorList : System.Web.UI.Page
    {
        IAccountManager accountManager = new AccountManager();
        protected void Page_Load(object sender, EventArgs e)
        {
            //权限检查
            if (!IsPostBack)
            {
                bindOperator();
            }
            else
            {
                
            }

        }

        private void bindOperator()
        {
            operList.DataSource=accountManager.getOperatorDs();
            operList.DataBind();
        }
        protected void operList_RowDataBound(object sender, GridViewRowEventArgs e)
        {

        }

        protected void operList_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int id = Convert.ToInt32(this.operList.Rows[e.RowIndex].Cells[0].Text);
            if (accountManager.deletOperator(id))
            {
                RegisterStartupScript("", "<script>alert('删除成功！')</script>");
                operList.DataSource = accountManager.getOperatorDs();
                operList.DataBind();
            }
            else
            {
                RegisterStartupScript("", "<script>alert('删除失败！')</script>");
            }
        }
        protected void operList_RowEditing(object sender, GridViewEditEventArgs e)
        {
            
        }
        protected void operList_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {

        }

        protected void DlPage_Init(object sender, EventArgs e)//DlPage就是分页中的下拉列表框
        {
            DropDownList list = (DropDownList)sender;
            for (int i = 1, j = operList.PageCount; i <= j; i++)
            {
                list.Items.Add(new ListItem(i.ToString()));
            }
            list.SelectedIndex = operList.PageIndex;
        }
        protected void DlPage_SelectedIndexChanged(object sender, EventArgs e)//DlPage就是分页中的下拉列表框
        {
            DropDownList list = (DropDownList)sender;
            operList.PageIndex = list.SelectedIndex;
            bindOperator();
        }
    }
}